package se.hrbustrc.hlgshopping.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import se.hrbustrc.hlgshopping.entity.Product;
import se.hrbustrc.hlgshopping.entity.Prosku;
import se.hrbustrc.hlgshopping.mapper.ProskuMapper;
import se.hrbustrc.hlgshopping.service.ProductService;
import se.hrbustrc.hlgshopping.mapper.ProductMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author qianbimo
* @description 针对表【tb_product】的数据库操作Service实现
* @createDate 2025-09-04 09:38:59
*/
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product>
    implements ProductService {
    @Autowired
    ProductMapper productMapper;
    @Autowired
    private ProskuMapper proSkuMapper;
    @Override
    public void addProduct(Product product) {
        productMapper.insert(product);
    }


    @Override
    public void editProduct(Product product) {
        productMapper.updateById(product);
    }

    @Override
    public void delProduct(int productId) {
        productMapper.deleteById(productId);
    }

    @Override
    public Product getProduct(int productId) {
        return productMapper.selectById(productId);
    }
    
    @Override
    public List<Product> getProductsByCategoryId(int categoryId) {
        QueryWrapper<Product> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("FPCatid", categoryId);
        return productMapper.selectList(queryWrapper);
    }
    
    @Override
    public List<Product> getProductsByCategoryIds(List<Integer> categoryIds) {
        QueryWrapper<Product> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("FPCatid", categoryIds);
        return productMapper.selectList(queryWrapper);
    }

}




